/***************************************************************************************
Firm-embedded productivity and cross-country income differences
Alviarez, Cravino and Ramondo
Journal of Political Economy (2022)

Program: table_A1_gravity_coef.do
Date: October 2022

Description: Reproduces Table A.1: Estimates of gravity coeficients.

*****************************************************************************************/

*-------------------------------------------------------------------------------
global typeden=1
include "set_directories.do"
set memory 64g
global lf "LF"

*Log
cap log close
log using "${clogs}/table_A1_gravity_coef.log",replace
*-------------------------------------------------------------------------------

local title "naics_sales_s1_base_woparent"
clear all
use "${data}/gravitycoef_`title'.dta", clear
keep sector coef_* se_*


gen sector_order="NA"

*Other goods
*---------------------------------------
replace sector_order="1.1" if sector=="AgrMining (A-B)"
replace sector_order="1.2" if sector=="Electricity (D-E)"
replace sector_order="1.2" if sector=="Construction (F)"

*Manufacturing
*---------------------------------------
replace sector_order="2.1" if sector=="Food (10-12)"
replace sector_order="2.2" if sector=="TexWood (13-18)"
replace sector_order="2.3" if sector=="ChePetPla (19-23)"
replace sector_order="2.4" if sector=="Basic Metals (24-25)"
replace sector_order="2.5" if sector=="ElecMach (26-28)"
replace sector_order="2.6" if sector=="TranspOtherManuf (29-33)"

*Services
*---------------------------------------
replace sector_order="3.1" if sector=="Wholesale_Retail (G)"
replace sector_order="3.2" if sector=="Transportation_Storage (H)"
replace sector_order="3.3" if sector=="Information (J)"
replace sector_order="3.4" if sector=="Financial_Insurance (K)"
replace sector_order="3.5" if sector=="Support_Services (M-N)"
replace sector_order="3.6" if sector=="Accomod_Recreat (I-R-S)"

*Other sectors
*---------------------------------------
replace sector_order="4.1" if sector=="Education (P)"
replace sector_order="4.2" if sector=="Health (Q)"
replace sector_order="4.3" if sector=="Real_Estate (L)"

drop if sector=="Public_Administration (O)"
sort sector_order
order sector_order sector

format %9.3fc coef_* se_*

export delimited using "${rappendix}/table_A1_gravity_coef.csv", datafmt replace
